package lesson16;

public class Person 
{
	public String name;
	String adress;
	private String egn;
	private int age;
	private String password; //set in constructor
	// make method changePassword(String oldPass, String newPass)
	City c = new City();
	
	public Person(String egn, String password)
	{
		name = "Ivan";
		age = 0;
	}
	
	public boolean validateAge()
	{
		int age = getAge(password);
		return age > 0;
	}
	
	
	
	public Person(String password)
	{
		this.password = password;
	}
	
	public void changePassword(String oldPass, String newPass, String newPass2)
	{
		if(newPass.equals(newPass2))
		{
			if(this.password.equals(oldPass))
			{
				this.password = newPass;
			}
			else
			{
				System.out.println("Password wrong");
			}
		}
		else
		{
			System.out.println("New password wrong");
		}
	}
	
	
	
	void setAge(int age)
	{
		if(age>=0 && age < 200)
		this.age = age;
	}
	int getAge(String passowrd)
	{
		if(this.password.equals(password))
		return age;
		else
			return -1;
	}
}
